<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<%
	String path = request.getContextPath();
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>怎么就不好使呢</title>

<link rel="stylesheet" href="<%=path%>/easyui/themes/default/easyui.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="<%=path%>/easyui/themes/icon.css"
	type="text/css" media="screen" />
<link rel="stylesheet" href="<%=path%>/css/main.css" type="text/css"
	media="screen" />
<link rel="stylesheet" type="text/css" href="<%=path%>/css/Tooltip.css" />
<script src="<%=path%>/easyui/jquery-1.4.4.min.js"></script>
<script src="<%=path%>/easyui/jquery.easyui.min.js"></script>
<!-- mytab -->
<script src="<%=path%>/myjs/myTab.js"></script>
<!-- sys -->
<script src="<%=path%>/myjs/sys.js"></script>
<script src="<%=path%>/easyui/easyMask.js"></script>
<script src="<%=path%>/easyui/easyUI.js"></script>
<script src="<%=path%>/easyui/easyLayer.js"></script>
<script src="<%=path %>/myjs/casePropertyStorage.js"></script>
<script src="<%=path %>/myjs/util.js"></script>
<script src="<%=path%>/myjs/DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
 	var proName = '<%=path%>';
 	var objs = [];  //全局变量
 	var selectRow = []; //临时变量，用来记录分页加载页面时设置选中行
	var greyLayer ;
	$(function(){
		
		grid = $('#tt').datagrid({
			url:proName+'/casePropertyStorage/getUnStoreGoods',
			height:$('#query_condition').height()-$('#search_table').height(),
			pagination:true,
			singleSelect:false,
			//fit:true,//表格自动填充
			loadMsg:'正在努力为您加载，请稍作等待…',//加载信息
			pageSize:10,
			rowStyler:function(index, row, css){
				//从选中的数据里判断是否要添加样式，如果有选中的数据，把index push到selectRow中
				for(var i=0;i<objs.length;i++){
					if(objs[i].goods_id==row.goods_id){
						selectRow.push(index);
					}
				}
			},
			
			onLoadSuccess:function(){
				//加载数据成功后，添加样式，将rowStyler方法中push的selectRow取出来，并设置选中状态。selectRow清空
				grid.datagrid('clearSelections');
				while(selectRow.length>0){
					 grid.datagrid('selectRow', selectRow.shift());
				}
			},
			
			onSelect:function(rowIndex, rowData){
				if(objs.length==0){
					objs.push(rowData);
				}else if(objs[0].case_num==rowData.case_num){
					for(var i=0;i<objs.length;i++){
						if(objs[i].goods_id!=rowData.goods_id){
							objs.push(rowData);
							break;
						}
					}
				}else{
					sys_alert('错误提示', '请选择同一案件的物品进行入库', 'error');
					var selects = $('.datagrid-row-selected');
					for(var i=0;i<selects.length;i++){
						var select = selects.eq(i);
						if(select.attr('datagrid-row-index')==rowIndex){
							select.removeClass('datagrid-row-selected');
						}
					}
				}
				
			},
			onUnselect:function(rowIndex, rowData){
				objs.removeGoods(rowData);
			},
			toolbar:[{
				text:'查询',
				iconCls:'icon-function',
				handler:'search'
				// handler:'func_sys_priv_menu'
			},'-',{
				text:'登记入库',
				iconCls:'icon-add',
			 	handler:'handleStore'
			},'-',{
				text:'打印',
				iconCls:'icon-function'
				// handler:'func_sys_priv_menu'
			},'-',{
				text:'查看明细',
				iconCls:'icon-function'
				// handler:'func_sys_priv_menu'
			}]
			
		});
		//初始化pagination工具开始
		var pagetool = $('#tt').datagrid('getPager');
		pagetool.pagination({				
				beforePageText:'第',
				afterPageText:'页，共{pages}页',
				displayMsg:'显示从 {from} 到  {to} , 总记录 {total} '});
		//初始化pagination工具结束
					
	
		$('body').layout();
		$('#btn-save,#btn-cancel').linkbutton();
		
		$('#WPSBDW').combobox({
			url:proName+"/casePropertyStorage/getCompanyInfo",
			multiple:false,
			onChange:function(newValue,oldValue){  
				$('#WPSBDW').val(newValue);
			}
		});
		$('#AJLB').combobox({
			url:proName+"/dicManager/getChildListByPcode?p_code=15",
			multiple:false,
			onChange:function(newValue,oldValue){  
				$('#AJLB').val(newValue);
			}
		});
//新增物品
		win_func = $('#win_function').window({
			collapsible:false,
			minimizable:false, 
			maximizable:false, 
			closable:true,
			onClose:function(){greyLayer.close();},
			closed:true,
			cache:false						
		});	
		form_func = win_func.find('form');	
		greyLayer = new easyMask(null,'100%','100%',100,'#000',8,true);
	});
	
</script>
</head> 
<body>

<div id="query_condition" region="center" style="overflow:hidden;padding: 1px 1px 1px 1px;">
	<form action="post" >
	<table id='search_table'>
		<tr>
			<td>案件编号：</td>
			<td><input type='text' id='AJBH' name='AJBH'/></td>
			<td>案件类别：</td>
			<td><input type='text' id='AJLB' name='AJLB' panelWidth="240px" valueField="c_code" textField="c_name"/></td>
			<td>案件名称：</td>
			<td><input type='text' id='AJMC' name='AJMC'/></td>
		</tr>
		<tr>
			<td>物品上报单位：</td>
			<td><input type='text' id="WPSBDW" name='WPSBDW' valueField="company_code" textField="company_name" panelWidth="240px"/></td>
			<td>物品上报人：</td>
			<td><input type='text' id='WPSBR' name='WPSBR'/></td>
			<td>上报时间：</td>
			<td><input name="SBSJ" class="easyui-validatebox"
							type="text" onClick="WdatePicker({dateFmt:'yyyyMMdd'});"></input></td>
		</tr>
	</table>
	</form>
	<table id="tt">
		<thead>
			<tr>
				<th field="goods_name" width="100%" class="easyui-validatebox">物品名称</th>
				<th field="case_name" width="150%" class="easyui-validatebox">案件名称</th>
				<th field="case_num" width="150%" class="easyui-validatebox">案件编号</th>
				<th field="goods_company" width="100%" class="easyui-validatebox" required="true">物品来源</th>
				<th field="goods_type" width="100%" class="easyui-validatebox" required="true">物品类型</th>
				<th field="enter_date" width="100%" class="easyui-validatebox">物品录入时间</th>
			</tr>
		</thead>
	</table>
	
	<div id="win_function" iconCls="icon-function" title="涉案物品入库登记"
		style="width: 100%; height: 375px;"  fit="true">
		<form id="form_function" name="form_function" method="post">
		<input type='hidden' name='selectedGoodsIds' id="selectedGoodsIds"/>
		<!-- left-div -->
		<div style="width:40%;float:left;">
			<div id="data_div" >
				<input type='hidden' id='gridID' name='gridID'>
				<table id="data_div_table">
					<tbody>
						<tr>
							<td>条形码：</td>
							<td><input type='text' id="t_code" name='t_code'/></td>	
							<td>
								<input type='button' onclick='doSave()' value='入库保存'/>
							</td>		
						</tr>
						<tr>
							<td>保管室：</td>
							<td><input type='text' id="room_id" name="room_id" valueField="room_id" textField="room_name" multiple="false" panelHeight="200px" panelWidth="200px"/></td>
							<td>保管柜：</td>
							<td><input type='text' id="shelf_id" name='shelf_id' valueField="shelf_id" textField="shelf_name" multiple="false" panelHeight="200px" panelWidth="200px"/></td>
						</tr>
					</tbody>
				</table>
			</div>
			<div id="select_goods_div" class="panel datagrid" style="position:relative;bottom:20px">
				<table id='select_table'>
					<thead>
						<tr>
							<th field="goods_name" width='100' class="easyui-validatebox">
								物品名称
							</th>
							<th field="case_name" width='98' class="easyui-validatebox">
								案件名称
							</th>
							<th field="case_num" width='100' class="easyui-validatebox">
								案件代码
							</th>
							<th field="goods_id" width='98' class="easyui-validatebox">
								物品代码
							</th>
						</tr>
					</thead>
					<tbody id='select_table_data_body'>
						
					</tbody>
					
				</table>
			</div>
		</div>
		<!-- right-div -->
		<div style="width:60%;height:100%;float:right;" >
			<div id="gridDiv">
				
			</div>
			<div id="gridGoodsDiv" style="display:none">
				<table id='gridGoodsDiv_table'>
					<thead>
						<tr>
							<th field="goods_name" width='100' class="easyui-validatebox">
								物品名称
							</th>
							<th field="case_name" width='98' class="easyui-validatebox">
								案件名称
							</th>
							<th field="goods_tcode" width='100' class="easyui-validatebox">
								条形码
							</th>
							<th field="create_date" width='98' class="easyui-validatebox">
								入库日期
							</th>
						</tr>
					</thead>
					<tbody id='gridGoodsDiv_data_body'>
						
					</tbody>
					
				</table>
			</div>
		</div>
	
	</form>
</div>
</div>
</body></html>

